<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>wish商品上传及同步</title>
<body class="withvernav">
<div class="bodywrapper"> {{include file='/public/leftmenu.tpl'}}
  <div class="centercontent">
    <div class="pageheader notab">
      <h1 class="pagetitle">wish商品上传及同步</h1>
       <div class="menulist">
                <ul class="profile_summary">
                      <li> <a href="javascript:void(0)" onClick="creatproduct()" ><span>批量上传产品到店铺</span></a></li>     
                     <li> <a href="javascript:void(0)" onClick="savecsv()" ><span>批量导入</span></a></li>
                    <li> <a href="ajaxbutton?op=creatproduct&type=0"  ><span>创建新产品</span></a></li>
                    <li> <a href="javascript:void(0)" onClick="delectall()" ><span>删除多个产品</span></a></li>
                    <li> <a href="ajaxbutton?op=status"  ><span>查看上传商品状态</span></a></li>                
                </ul>
            </div>
    <form class="stdform stdform2" method="get" id="search" action="/Wishproduct/ajaxbutton">

      <div class="tableoptions">
      <input type="hidden" name="op" value="search">
       <input type="text" name="kw" id="kw" class="width200" value="{{$kw}}" placeholder="关键词" />
&nbsp;
        <button class="btn btn-primary" id="searchbtn">Search</button>

        
      </div>
      
    
    </form>


   <!--搜索栏结束-->
<table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="table-layout: fixed;">
<thead>
  <tr class="lbbt">
    <td width="3%"  bgcolor="#FEFFF1"><a onClick="allSelect('ppid[]')">全选</a></td>
    <td width="8%" bgcolor="#FEFFF1">父级sku</td>
    <td width="8%" bgcolor="#FEFFF1">商品sku</td>
    <td width="8%" bgcolor="#FEFFF1">商品图片</td>
    <td width="10%" bgcolor="#FEFFF1">商品名称</td>
    <td width="10%"  bgcolor="#FEFFF1">颜色</td>
    <td width="10%" bgcolor="#FEFFF1">尺码</td>
    <td width="5%" bgcolor="#FEFFF1">数量</td>
    <td  bgcolor="#FEFFF1">价格</td>
    <td width="10%" bgcolor="#FEFFF1" >运费</td>
    <td width="10%" bgcolor="#FEFFF1" >上传时间</td>
    <td width="10%" bgcolor="#FEFFF1" >选择</td>
  </tr>
</thead>
<tbody >

{{foreach from=$productlist item=li key=key}}
  <tr  style="cursor:pointer;">
    <td >
        <input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.wish_id}}" />
    </td>
     <td>{{$li.Parent_Unique_ID}}</td>
     <td>{{$li.Unique_ID}}</td>
     <td><img src="{{$li.Main_Image_URL}}" style="width: 30%"></td>
    <td>{{$li.Product_Name}}</td>

    <td style="position:relative;">
   
      <div style="margin-left:2px;">{{$li.Color}}

    </div>
   </td>
    <td valign="middle">{{$li.Size}}</td>
   
    <td class="cz">
        {{$li.Quantity}}
    </td>
    <td>{{$li.Price}}</td>
    <td>{{$li.Shipping}}</td>
    <td class="cz">{{$li.updatatime}}</td>
    <td class="cz"><a href="ajaxbutton?op=creatproduct&type=1&id={{$li.wish_id}}"><button>编辑</button></a><button onclick="delect({{$li.wish_id}})">删除</button></td>
  </tr>
{{/foreach}}
</tbody>

</table>









     </div>
 </div>

 <!-- 模态框（Modal）打印内容 -->
        <form action="/wishproduct/ajaxbutton?op=savebatchexcel"  method="post" name="outcsvform" id="outcsvform" enctype="multipart/form-data">
           <div class="modal fade" id="wishproductform" tabindex="-1" role="dialog" aria-labelledby="sexpressform" aria-hidden="true">
                <div class="modal-dialog" style="width:740px;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"
                                    aria-hidden="true">× </button>
                            <h4 class="modal-title" id="sprintform"> 导入Excel文档  </h4>
                        </div>
                        <div class="modal-body">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td width="100">Excel： </td>
                                    <td align="left"><input type="file" name="upfile" class="width200"></td>
                                </tr>

                                <tr>
                                    <td>注意： </td>
                                    <td align="left">必须严格按照模板导入&nbsp;</td>
                                </tr>
                            </table>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default"
                                        data-dismiss="modal"> 关闭 </button>
                                <button type="button" class="btn btn-primary"  onclick="outcsvsubmit()"> 提交 </button>
                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
            </div>
            </form>
            <!-- /.modal -->

<!-- 模态框（Modal）打印内容 -->
        <form action="/wishproduct/ajaxbutton?op=saveupload"  method="post" name="outcsvform" id="outcsvform" enctype="multipart/form-data">
           <div class="modal fade" id="wishcreatproduct" tabindex="-1" role="dialog" aria-labelledby="sexpressform" aria-hidden="true">
                <div class="modal-dialog" style="width:740px;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"
                                    aria-hidden="true">× </button>
                            <h4 class="modal-title" id="sprintform"> 上传产品到店铺  </h4>
                        </div>
                        <div class="modal-body">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td width="100">已选择的商品id： </td>
                                    <td align="left"><textarea name="productid"  id="productid" rows="4" cols="110" class="full_input" readonly=""></textarea></td>
                                </tr>
                                <tr>
                                    <td width="100">选择需要上传的店铺： </td>
                                    <td align="left"><div id="wishshop"></div></td>
                                </tr>

                            </table>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default"
                                        data-dismiss="modal"> 关闭 </button>
                                <button type="button" class="btn btn-primary"  onclick="saveupload()"> 提交 </button>
                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
            </div>
            </form>
            <!-- /.modal -->

<script type="text/javascript">
function outcsvsubmit()
  {
    $("#wishproductform").modal('hide');
    $("#outcsvform").submit();  
  }

function savecsv()
  {
    $('#wishproductform').modal('show');
  }
function creatproduct(){
    $('input:checkbox[name=ppid[]]:checked').each(function(i){
       if(0==i){
        spCodesTemp = $(this).val();
       }else{
        spCodesTemp += (","+$(this).val());
       }
      });
      $("#productid").val(spCodesTemp);

 $.post("/wishproduct/ajaxbutton?op=setshop",
                    function(data){
                        $("#wishshop").html(data);
                    });

  $('#wishcreatproduct').modal('show');
}

function saveupload(){
 var productid= $('#productid').val();
    $('input:checkbox[name=shopid]:checked').each(function(i){
       if(0==i){
        sspCodesTemp = $(this).val();
       }else{
        sspCodesTemp += (","+$(this).val());
       }
      });
    // alert(productid);
$.post("/wishproduct/ajaxbutton?op=saveupload",{productid:productid,shopid:sspCodesTemp},
  function(data){
    alert('success');
    document.location.href = data;
  }
  );


}

function delect(id){
$.post("/wishproduct/ajaxbutton?op=delect",{id:id},
  function(data){
     document.location.href = data;
  }
  );

}

function delectall(){
   $('input:checkbox[name=ppid[]]:checked').each(function(i){
       if(0==i){
        opt = $(this).val();
       }else{
        opt += (","+$(this).val());
       }
      });
$.post("/wishproduct/ajaxbutton?op=delect",{id:opt},
  function(data){
     document.location.href = data;
  }
  );


}

</script>







</body>
</html>